<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:fragment="comments(pageType)">
<body>
<div th:if="${article}!=null">
    <div th:id="${article.cid ?: 0}" class="comment-container">
        <div id="comments" class="clearfix">
            <div th:if="${article.allowComment}">
                <span class="response">
                    <th:block th:if="${session.login_user}">
                        Hi，<a th:href="${session.login_user.home_url}" data-no-instant=""
                              th:text="${session.login_user.username}"></a>
                        如果你想 <a href="/logout" title="注销" data-no-instant="">注销</a> ?
                    </th:block>
                </span>
                <form method="post" id="comment-form" class="comment-form" role="form"
                      onsubmit="return TaleComment.subComment();">
                    <input type="hidden" name="coid" id="coid"/>
                    <input type="hidden" name="cid" id="cid" th:value="${article.cid}"/>
                    <input type="hidden" name="_csrf_token" th:value="${_csrf_token}"/>
                    <input type="text" name="author" maxlength="12" id="author"
                           class="form-control input-control clearfix"
                           placeholder="昵称 (*)"
                    />
                    <input type="email" name="mail" id="mail" class="form-control input-control clearfix"
                           placeholder="邮箱 (*)"
                    />
                    <input type="url" name="url" id="url" class="form-control input-control clearfix"
                           placeholder="网址 (http://)"
                    />
                    <textarea name="text" id="textarea" class="form-control" placeholder="基佬~留下你的裤衩~"
                              required="required" minlength="5"
                              maxlength="2000"></textarea>
                    <button type="submit" class="submit" id="misubmit" style="cursor:pointer">评论</button>
                </form>
            </div>
            <div th:unless="${article.allowComment}">
                <span class="response">该文章评论已关闭</span>
            </div>

            <div th:if="${comments}">
                <ol class="comment-list">
                    <th:block th:each="comment :${comments.list}">
                        <li th:id="'li-comment-'+${comment.coid}" class="comment-body comment-parent comment-odd">
                            <div th:id="'comment-'+${comment.coid}">


                                <div class="comment-view">
                                    <div class="comment-header">
                                        <!--设置get请求的参数-->
                                        <img class="avatar"
                                             th:src="@{${commons.gravatar(comment.ip)}(d='wavatar',s='40')}"
                                             th:title="${comment.author}"
                                             width="80" height="80"/>
                                        <span class="comment-author">
                                            <a th:href="${comment.url}" target="_blank" rel="external nofollow" th:text="${comment.author}"></a>
                                        </span>
                                    </div>
                                    <div class="comment-content">
                                        <span class="comment-author-at">
                                            <!--<a href="#comment-884">@zzz</a>-->
                                        </span>
                                        <p th:utext="${commons.article(comment.content)}"></p>
                                    </div>
                                    <div class="comment-meta">
                                        <time class="comment-time" th:text="${commons.fmtdate(comment.created)}"></time>
                                        <span class="comment-reply">
                                            <a rel="nofollow" th:onclick="'javascript:TaleComment.reply(\''+${comment.coid}+'\',\''+'@'+${comment.author}+'\')'">回复</a>
                                        </span>
                                    </div>
                                </div>

                                <th:block th:if="${comment.commentsList.size() != 0}">
                                    <th:block th:each="childComments :${comment.commentsList}">
                                        <div class="comment-view" th:id="'comment-'+${childComments.coid}" style="margin-left: 50px">
                                            <div class="comment-header">
                                                <img class="avatar"
                                                     th:src="@{${commons.gravatar(childComments.ip)}(d='wavatar',s='40')}"
                                                     th:title="${childComments.author}"
                                                     width="80" height="80"/>
                                                <span class="comment-author">
                                                    <a th:href="${childComments.url}" target="_blank" rel="external nofollow" th:text="${childComments.author}"></a>
                                                </span>
                                            </div>
                                            <div class="comment-content">
                                                <span class="comment-author-at">
                                                    <!--<a href="#comment-884">@zzz</a>-->
                                                </span>
                                                <p th:utext="${commons.article(childComments.content)}"></p>
                                            </div>
                                            <div class="comment-meta">
                                                <time class="comment-time" th:text="${commons.fmtdate(childComments.created)}"></time>
                                                <span class="comment-reply">
                                                    <a rel="nofollow" th:onclick="'javascript:TaleComment.reply(\''+${comment.coid}+'\',\''+'@'+${childComments.author}+'\')'">回复</a>
                                                </span>
                                            </div>
                                        </div>
                                    </th:block>
                                </th:block>

                            </div>
                        </li>
                    </th:block>
                </ol>

                <div class="lists-navigator clearfix">
                    <div th:replace="comm/macros::pageNav(${comments},'Previous','Next',${pageType},'#comments')"></div>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
<div th:replace="comm/tale_comment::tale_comment"></div>
</html>